package com.zxkj.commonpatrol.repoisity;

import com.allen.library.base.BaseHttpUtil;
import com.allen.library.factory.ApiFactory;
import com.allen.library.interceptor.Transformer;
import com.allen.library.observer.CommonObserver;
import com.czy.basecommon.utils.base.BaseRepository;
import com.czy.basecommon.utils.constant.ItrackConstant;
import com.czy.basecommon.utils.tools.GsonUtil;
import com.czy.basecommon.utils.tools.SPUtils;
import com.zxkj.commonpatrol.model.entity.CheckPointListEntity;
import com.zxkj.commonpatrol.model.entity.SelectProjectEntrity;
import com.zxkj.commonpatrol.model.post.PostCheckPointDetail;
import com.zxkj.commonpatrol.model.post.PostPointInfo;
import com.zxkj.commonpatrol.model.response.PointPatrolDetailResponse;
import com.zxkj.commonpatrol.net.ETFApiHelper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import okhttp3.ResponseBody;

public class CheckPointDetailRepoisity extends BaseRepository {
    public CheckPointDetailRepoisity() {

    }

    //初始化選擇項目列表
    public void  getData(int type,MyBaseDataCallBack< List<CheckPointListEntity>> mDataCallBack){






        List<CheckPointListEntity> datas=new ArrayList<>();


            for (int i = 3; i < 6; i++) {
                CheckPointListEntity entity =new CheckPointListEntity();
                entity.setType(1);
                entity.setAddress("深圳"+i);
                entity.setCp_nb("CP1002"+i);
                entity.setDecive_type("手機"+i);
                entity.setNum("3");
                entity.setLast_time("2020/09/01");
                entity.setPeople("Danny");
                if (i%2==0){
                    entity.setStatus(0);
                }else{
                    entity.setStatus(1);
                }
                entity.setZs_nb("DP1002"+i);
                entity.setTitle("Decive"+i);

                datas.add(entity);
            }

            for (int i = 0; i < 3; i++) {
                CheckPointListEntity entity =new CheckPointListEntity();
                entity.setType(2);
                entity.setAddress("香港"+i);
                entity.setLast_time("2020/09/01");
                entity.setNum("4");
                entity.setPeople("KK");
                entity.setEvent_code("EP1003"+i);
                if (i%2==0){
                    entity.setStatus(0);
                }else{
                    entity.setStatus(1);
                }

                entity.setTitle("Event"+i);
                entity.setQuest_list("火箭問題");
                datas.add(entity);
            }


        mDataCallBack.onDataSuccessCallBack(datas);

    }

    //

    public  void  getDetailData(String RouteInspectNo,String  PointNo,String  Filter,MyBaseDataCallBack mDataCallBack){


        HashMap<String,Object> map=new HashMap<String, Object>();
        map.put("LoginId", SPUtils.get(ItrackConstant.LOGINID,""));
        map.put("Token", SPUtils.get(ItrackConstant.TOKEN,""));
        map.put("Lang", 1);
        PostCheckPointDetail bean=new PostCheckPointDetail();
        bean.setRouteInspectNo(RouteInspectNo);
        bean.setPointNo(PointNo);
        bean.setFilter(Filter);

        ETFApiHelper.geRadomApi().GetPointPatrolDetail(map,new BaseHttpUtil<PostCheckPointDetail>().convertVo2Json(bean))
                .compose(Transformer.<PointPatrolDetailResponse>switchSchedulers())
                .subscribe(new CommonObserver<PointPatrolDetailResponse>() {

                    @Override
                    protected void onError(String errorMsg) {
                        mDataCallBack.onDataFailCallBack(404,errorMsg);
                    }

                    @Override
                    protected void onSuccess(PointPatrolDetailResponse s) {

                        //回调数据
                        mDataCallBack.onDataSuccessCallBack(s);
                    }
                });


    }

}
